/* eslint-disable react/prop-types */
import { CopyOutlined } from "@ant-design/icons"
import { Button } from "antd"

import { Toast } from "@/components/messages"
import { useLocale } from "@/locales"
interface ISaveButton {
	value: string
}
export const SaveButton: React.FC<ISaveButton> = ({ value }) => {
	const { formatMessage } = useLocale()
	const handleCopy = () => {
		navigator.clipboard
			.writeText(value)
			.then(() => {
				Toast.success(formatMessage({ id: "member.modal.success" }))
			})
			.catch(() => {
				Toast.error(formatMessage({ id: "member.modal.fail" }))
			})
	}
	return <Button onClick={handleCopy} icon={<CopyOutlined />}></Button>
}
